package com.vitabuybuy.tv.ui.mine.setting

import android.os.Bundle
import com.vitabuybuy.tv.R
import com.vitabuybuy.tv.databinding.ActivityFeelbackBinding
import com.library.common.base.BaseActivity
import com.library.common.base.MessageModel
import com.library.common.toast.XToast
import com.vitabuybuy.tv.ui.mine.setting.viewmodel.FeelBackViewModel
import kotlinx.android.synthetic.main.activity_feelback.*

class FeedbackActivity : BaseActivity<FeelBackViewModel, ActivityFeelbackBinding>() {
    override val isUseBaseTitleBar: Boolean
        get() = true
    override val layoutId: Int
        get() = R.layout.activity_feelback

    override fun initView(savedInstanceState: Bundle?) {
        setTitle(getString(R.string.feedback))
    }
    override fun eventHandling() {
        btnSubmit.setOnClickListener {
            when {
                etContent.text.isEmpty() -> XToast.normal(getString(R.string.pls_enter_your_feel_back))
                else -> {
                    viewModel.saveFeelBack(etContent.text.toString())
                }
            }
        }
    }

    override fun handleEvent(msg: MessageModel) {
        when(msg.code){
            1->{
                XToast.success(getString(R.string.thank_your_feel_back))
                finish()
            }
        }
    }

    companion object {
        fun openActivity(mContext: BaseActivity<*, *>) {
            mContext.startActivity(null, FeedbackActivity::class.java)
        }
    }
}